<template>
  <div class="">
    <ul>
      <li v-for="(item, index) in history" :key="index">
        {{ item }}========<span @click="remove(index)">x</span>
      </li>
    </ul>
    <button @click="clear">删除全部</button>
  </div>
</template>

<script>
import { ref, reactive, toRefs, computed } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
export default {
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({});
    const history = computed(() => {
      return store.state.history;
    });

    const remove = (index) => {
      store.commit("remove", index);
    };

    const clear = () => {
      store.commit("clear");
    };
    return { ...toRefs(data), history, remove, clear };
  },
};
</script>

<style lang="scss"></style>
